
local path = minetest.get_modpath(minetest.get_current_modname()) .. "/"

-- Variables for objects with MCL2 compatibility

glass_bottle = "vessels:glass_bottle"
meat_raw = "mobs:meat_raw"
meat = "mobs:meat"
axe_stone = "default:axe_stone"
sword_steel = "default:sword_steel"
pick_steel = "default:pick_steel"
shovel_steel = "default:shovel_steel"
wheat = "farming:wheat"
bread = "farming:bread"
bucket_water = "bucket:bucket_water"
mushroom_red = "flowers:mushroom_red"
jungletree = "default:jungletree"
flint_and_steel = "fire:flint_and_steel"
leather = "mobs:leather"
tree = "default:tree"
cactus = "default:cactus"
papyrus = "default:papyrus"
wood = "default:wood"
stone = "default:stone"
desert_stone = "default:desert_stone"
sapling = "default:sapling"
acacia_sapling = "default:acacia_sapling"
aspen_sapling = "default:aspen_sapling"
bug_net = "fireflies:bug_net"
lay_lump = "default:clay_lump"
clay = "default:clay"
glass = "default:glass"
ice = "default:ice"
coral_orange = "default:coral_orange"
coral_brown = "default:coral_brown"
iron_lump = "default:iron_lump"
copper_lump = "default:copper_lump"
copper_ingot= "default:copper_ingot"
steel_ingot = "default:steel_ingot"
gold_lump = "default:gold_lump"
gold_ingot = "default:gold_ingot"
tinblock = "default:tinblock"
tin_lump = "default:tin_lump"
tin_ingot = "default:tin_ingot"
mese_crystal_fragment = "default:mese_crystal_fragment"
dirt_with_grass = "default:dirt_with_grass"
obsidian_shard = "default:obsidian_shard"
mossycobble = "default:mossycobble"
obsidian = "default:obsidian"
diamond = "default:diamond"
diamondblock = "default:diamondblock"
ladder = "default:ladder"
stick = "default:stick"
brick = "default:brick"
permanent_flame = "fire:permanent_flame"
permafrost_with_moss = "default:permafrost_with_moss"
blueberries = "default:blueberries"
apple = "default:apple"
grass_3 = "default:grass_3"
sign_wall = "default:sign_wall"
meatblock = "mobs:meatblock"

sandstone_texture = "default_sandstone.png"
stone_texture = "default_stone.png"
meat_texture = "mobs_meat_raw.png"

if minetest.get_modpath("mcl_core") ~= nil then
   glass_bottle = "mcl_potions:glass_bottle"
   meat_raw = "mcl_mobitems:beef"
   meat = "mcl_mobitems:cooked_beef"
   axe_stone = "mcl_tools:axe_stone"
   sword_steel = "mcl_tools:sword_iron"
   pick_steel = "mcl_tools:pick_iron"
   shovel_steel = "mcl_tools:shovel_iron"
   wheat = "mcl_farming:wheat_item"
   bread = "mcl_farming:bread"
   bucket_water = "mcl_buckets:bucket_water"
   mushroom_red = "mcl_mushrooms:mushroom_red"
   jungletree = "mcl_core:jungletree"
   flint_and_steel = "mcl_fire:flint_and_steel"
   leather = "mcl_mobitems:leather"
   tree = "mcl_core:tree"
   cactus = "mcl_core:cactus"
   papyrus = "mcl_core:paper"
   wood = "mcl_core:wood"
   stone = "mcl_core:stone"
   desert_stone = "mcl_core:sandstone"
   sapling = "mcl_core:sapling"
   acacia_sapling = "mcl_core:acaciasapling"
   aspen_sapling = "mcl_core:birchsapling"
   bug_net = "mcl_beds:bed_red"
   clay_lump = "mcl_core:clay_lump"
   clay = "mcl_core:clay"
   glass = "mcl_core:glass"
   ice = "mcl_core:ice"
   coral_orange = "mcl_ocean:brain_coral"
   coral_brown = "mcl_ocean:bubble_coral"
   iron_lump = "mcl_raw_ores:raw_iron"
   copper_lump = "mcl_copper:raw_copper"
   copper_ingot = "mcl_copper:copper_ingot"
   steel_ingot = "mcl_core:iron_ingot"
   gold_lump = "mcl_raw_ores:raw_gold"
   gold_ingot = "mcl_core:gold_ingot"
   tinblock = "mcl_core:ironblock"
   tin_lump = "mcl_core:iron_nugget"
   tin_ingot = "mcl_core:iron_ingot"
   mese_crystal_fragment = "mcl_core:diamond"
   dirt_with_grass = "mcl_core:dirt_with_grass"
   obsidian_shard = "mcl_amethyst:amethyst_block"
   mossycobble = "mcl_core:mossycobble"
   obsidian = "mcl_core:obsidian"
   diamond = "mcl_core:diamond"
   diamondblock = "mcl_core:diamondblock"
   ladder = "mcl_core:ladder"
   stick = "mcl_core:stick"
   brick = "mcl_core:stonebrick"
   permanent_flame = "mcl_nether:magma"
   permafrost_with_moss = "mcl_core:frosted_ice"
   blueberries = "mcl_farming:carrot"
   apple = "mcl_core:apple"
   grass_3 = "mcl_flowers:tallgrass"
   sign_wall = "mcl_signs:wall_sign"
   meatblock = "mcl_farming:pumpkin"

   sandstone_texture = "mcl_core_sandstone_normal.png"
   stone_texture = "default_stone.png"
   meat_texture = "mcl_mobitems_beef_raw.png"


end

if minetest.get_modpath("mcl_fireflies") ~= nil then
   bug_net = "mcl_fireflies:bug_net"
end


-- Check for translation method
local S
if minetest.get_translator ~= nil then
	S = minetest.get_translator("mobs_npc") -- 5.x translation function
else
	if minetest.get_modpath("intllib") then
		dofile(minetest.get_modpath("intllib") .. "/init.lua")
		if intllib.make_gettext_pair then
			S = intllib.make_gettext_pair() -- new gettext method
		else
			S = intllib.Getter() -- old text file method
		end
	else -- boilerplate function
		S = function(str, ...)
			local args = {...}
			return str:gsub("@%d+", function(match)
				return args[tonumber(match:sub(2))]
			end)
		end
	end
end

mobs_npc = {S = S}


-- Check for custom mob spawn file
local input = io.open(path .. "spawn.lua", "r")

if input then
	mobs.custom_spawn_npc = true
	input:close()
	input = nil
end


-- useful functions
dofile(path .. "functions.lua")

-- NPCs
dofile(path .. "npc.lua") -- TenPlus1
dofile(path .. "trader.lua")
dofile(path .. "igor.lua")


-- Load custom spawning
if mobs.custom_spawn_npc then
	dofile(path .. "spawn.lua")
end


-- Lucky Blocks
if minetest.get_modpath("lucky_block") then
	dofile(path .. "/lucky_block.lua")
end


print ("[MOD] Mobs Redo NPCs loaded")
